<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Project extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('project', ['comment' => '项目']);
        $table
            ->addColumn('project_title', 'string',array('limit' => 50,'null'=>true,'comment' => '项目名称'))
            ->addColumn('uid', 'integer',array('limit' => 11, 'comment' => '上传人'))
            ->addColumn('status', 'boolean',array('limit' => 1, 'default' => 1, 'comment' => '状态1显示2隐藏'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();

        $table = $this->table('project_target', ['comment' => '项目指标']);
        $table
            ->addColumn('project_id', 'integer',array('limit' => 11, 'comment' => '项目id'))
            ->addColumn('target_title', 'string',array('limit' => 550,'null'=>true,'comment' => '项目指标名称'))
            ->addColumn('time_limit', 'integer',array('limit' => 11,'default' => 1, 'comment' => '整改时限'))
            ->addColumn('standard', 'string',array('limit' => 50,'null'=>true,'comment' => '扣分规范'))
            ->addColumn('score', 'string',array('limit' => 50,'null'=>true,'comment' => '分值'))
            ->addColumn('uid', 'integer',array('limit' => 11, 'comment' => '上传人'))
            ->addColumn('duty_unit_id', 'integer',array('limit' => 11, 'comment' => '责任单位/整改单位'))
            ->addColumn('status', 'boolean',array('limit' => 1, 'default' => 1, 'comment' => '状态1显示2隐藏'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
